package com.ebai.product.management.controller.system;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ebai.product.management.base.cache.service.PublicCacheImpl;
import com.ebai.product.management.base.controller.WebController;
import com.ebai.product.management.base.utils.Common;
import com.ebai.product.management.model.entity.Code;
import com.ebai.product.management.model.entity.OperLog;
import com.ebai.product.management.service.system.OperLogService;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("/system/logs")
public class OperLogController extends WebController{
	
	@Autowired
	private OperLogService operLogService;

	@RequestMapping("/operlog/index")
	@RequiresPermissions("system:operlog:view")
    public String indexPage(ModelMap modelMap) {
    	modelMap.addAttribute("statusList", PublicCacheImpl.getDictListByCode("STATUS"));
        return "system/logs/operlog";
    }

    /**
     * AJAX调用分页数据信息
     * @param response HTTP响应
     * @param page 当前页码
     * @param limit 分页条数
     * @param sort 排序方式
     * @param order 排序字段
     * @param condition 查询条件
     */
    @RequestMapping("/operlog/pageList")
    public void jsonPageList(HttpSession session, HttpServletResponse response, 
    		int page, int limit, String sort, String order, OperLog condition) {
        JSONObject json = Common.getJsonDatagrid(this.operLogService.queryPage(page, limit, condition));
        this.sendDirectToClient(response, CONTENTTYPE_JSON, json.toString());
    }
}
